import {
  createWebHistory,
  createRouter,
} from "vue-router";

const Layout = () => import("@/layout/index.vue");

const routes = [
  {
    path: "/",
    name: "root",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        component: () => import("@/views/dashboard/index.vue"),
        name: "Dashboard",
        meta: {
          title: "dashboard",
          icon: "homepage",
          keepAlive: true,
        },
      },
    ],
  },

  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/index.vue"),
  },
  {
    path: "/404",
    name: "404",
    component: () => import("@/views/error-page/404.vue"),
    // 别名：当匹配到/:pathMatch(.*)*时，就会替换成/404
    alias: "/:pathMatch(.*)*",
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
